package red.stu.demo.pconstraint.demo;

import red.stu.pconstraint.ProcessUnit;
import red.stu.pconstraint.ProcessUtils;
import red.stu.pconstraint.annotation.ProcessBranch;
import red.stu.pconstraint.annotation.ProcessNode;
import red.stu.pconstraint.pojo.ProcessStorage;

/**
 * demo
 *
 * @author yihrmc@stu.red
 * @date 2019/11/13 16:40
 */
@ProcessBranch
public class MyProcessService {

    @ProcessNode
    public String createInfo(MyProcess process, String name) {
        ProcessUnit processUnit = ProcessUtils.get(process);
        String processInstanceId = processUnit.getProcessData().getProcessInstanceId();
        process.setProcessInstanceId(processInstanceId);

        processUnit.next();
        return null;
    }

    /**
     * 部门经理审核
     * @param process
     */
    @ProcessNode("p1")
    public void p1(MyProcess process) {
        // ProcessUtils.get(process).next();
        ProcessUtils.get(process).changeBranch("test");
    }

    @ProcessNode("p2")
    public void p2(MyProcess process) {

        // ProcessUtils.get(process).close(ProcessStorage.STATE_SUCCESS);

        ProcessUtils.get(process)
                .next();
    }

    @ProcessNode("p3")
    public void p3(MyProcess process) {
        ProcessUtils
                .get(process)
                .next();
    }

//    @ProcessBranch("b1")
//    @ProcessNode("p1")
//    public void b1_p1(MyProcess process) {
//        ProcessUtils.get(process).next();
//    }
//
//    @ProcessBranch("b1")
//    @ProcessNode("p2")
//    public void b1_p2(MyProcess process) {
//        ProcessUtils.get(process).next();
//    }

}
